package com.znwxss.handler.exception;

import com.znwxss.common.Result;
import com.znwxss.exception.BusinessException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 业务逻辑异常处理器
 * @Author: hb
 * @CreateTime: 2023-12-25 06:20
 * @Version: 1.0
 */
@RestControllerAdvice
@Slf4j
public class BusinessExceptionHandler {

    @ExceptionHandler(BusinessException.class)
    public Result<?> businessExceptionHandler(BusinessException e) {
        log.error("businessException: " + e.getMessage(), e);
        return Result.fail(e.getCode(), e.getMessage());
    }


}
